package org.rcloud.io.controller;

import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.model.ArticleCategoryMappingKey;
import org.rcloud.io.service.ArticleCategoryMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping(value = "/mapping")
@RestController
public class ArticleCategoryMappingController {

    @Autowired
    private ArticleCategoryMappingService acms;

    @RequestMapping("/addyear")
    @ResponseBody
    @CrossOrigin
    public ResultVo addYear(Integer articleId) {
        ArticleCategoryMappingKey articleCategoryMappingKey = new ArticleCategoryMappingKey();
        articleCategoryMappingKey.setArticleId(articleId);
        articleCategoryMappingKey.setCategoryId(103);
        return acms.add(articleCategoryMappingKey);
    }

    @RequestMapping("/addshow")
    @ResponseBody
    @CrossOrigin
    public ResultVo addShow(Integer articleId) {
        ArticleCategoryMappingKey articleCategoryMappingKey = new ArticleCategoryMappingKey();
        articleCategoryMappingKey.setArticleId(articleId);
        articleCategoryMappingKey.setCategoryId(92);
        return acms.add(articleCategoryMappingKey);
    }

    @RequestMapping("/delshow")
    @ResponseBody
    @CrossOrigin
    public ResultVo delShow(Integer articleId) {
        ArticleCategoryMappingKey articleCategoryMappingKey = new ArticleCategoryMappingKey();
        articleCategoryMappingKey.setArticleId(articleId);
        articleCategoryMappingKey.setCategoryId(92);
        return acms.del(articleCategoryMappingKey);
    }

    @RequestMapping("/delyear")
    @ResponseBody
    @CrossOrigin
    public ResultVo delYear(Integer articleId) {
        ArticleCategoryMappingKey articleCategoryMappingKey = new ArticleCategoryMappingKey();
        articleCategoryMappingKey.setArticleId(articleId);
        articleCategoryMappingKey.setCategoryId(110);
        return acms.del(articleCategoryMappingKey);
    }


}
